﻿#region

using System.ComponentModel;
using Radovici.SharedLibrary;
using YouTubePlaylist.MusicVideoService;

#endregion

namespace YouTubePlaylist.Models
{
    public class UserModel : Notifiable
    {
        #region Private fields

        private User _user;

        #endregion

        public User User
        {
            get { return _user; }
            set
            {
                _user = value;
                _user.PropertyChanged += OnUserChanged;
                Notify("User");
                Notify("IsUserLoggedIn");
            }
        }

        public bool IsUserLoggedIn
        {
            get
            {
                if (_user != null)
                {
                    return !string.IsNullOrEmpty(_user.ExternalKey);
                }
                return false;
            }
        }

        #region Private methods

        private void OnUserChanged(object sender, PropertyChangedEventArgs e)
        {
            Notify("IsUserLoggedIn");
        }

        #endregion
    }
}